let URL = "http://localhost:10000";
let URI = "/student-ui";
let IMG = "/rbac/images/upload/";
// $(function () {
//     isLogin();
// });
//判断用户是否登录
// function isLogin() {
//     let result = sessionStorage.getItem("isLogin");
//     if (result == null && result !== true) {
//         alert("请登录后操作！");
//         window.open("http://localhost:63342/step-seven-xadmin/propertyhtml/login.html", "_self");
//         return false;
//     }
//     return true;
// }
function ajax(url, data, type) {
    let result = {};
    let token = sessionStorage.getItem("token");
    $.ajax({
        url: URL + url,
        data: data,
        type: type,
        dataType: "json",
        async: false,//关闭异步刷新
        xhrFields: {
            //允许跨域带cookie
            withCredentials: true
        },
        beforeSend: function (request) {      //使用beforeSend
            request.setRequestHeader("Authorization", "Bearer " + token);
        },
        success: function (data) {
            console.log(data, "++++++++");
            result = data;//位于ajax内部局部变量，外部无法访问
        }
    });
    return result;
}
function myAjax(url, data, type) {
    let result = {};
    let token = sessionStorage.getItem("token");
    // console.log("token："+token);
    $.ajax({
        url: URL + url,
        data: data,
        type: type,
        dataType: "json",

        beforeSend: function (request) {      //使用beforeSend
            request.setRequestHeader("Authorization", "Bearer " + token);
        },
        async: false,//关闭异步刷新
        xhrFields: {
            //允许跨域带cookie
            withCredentials: true
        },
        success: function (data) {
            console.log(data, "++++++++");
            result = data;//位于ajax内部局部变量，外部无法访问
        }
    });
    return result;
}

function myImgAjax(url, data, type) {
    let result = {};
    let token = sessionStorage.getItem("token");
    $.ajax({
        url: URL + url,
        data: data,
        type: type,
        dataType: "json",
        async: false,//关闭异步刷新
        processData: false,//formData数据传输
        contentType:false,
        xhrFields: {
            //允许跨域带cookie
            withCredentials: true
        },
        beforeSend: function (request) {      //使用beforeSend
            request.setRequestHeader("Authorization", "Bearer " + token);
        },
        success: function (data) {
            result = data;
        }
    })
    return result;
}
function teamAjax(url, data, type) {
    let result = {};
    let token = sessionStorage.getItem("token");
    // console.log("token："+token);
    $.ajax({
        url: URL + url,
        data: data,
        type: type,
        dataType: "json",
        contentType:"application/json",
        beforeSend: function (request) {      //使用beforeSend
            request.setRequestHeader("Authorization", "Bearer " + token);
        },
        async: false,//关闭异步刷新
        xhrFields: {
            //允许跨域带cookie
            withCredentials: true
        },
        success: function (data) {
            console.log(data, "++++++++");
            result = data;//位于ajax内部局部变量，外部无法访问
        }
    });
    return result;
}

/**
 * 后台传值
 * @param data
 */
function adminLogin(data) {
    if (data.result == "noLogin") {
        window.open("http://localhost:63342/step-seven-xadmin/propertyhtml/login.html", "_self");
        return false;
    }
    return true;
}

/**
 * 清除模糊查询输入框中的数据
 */
/***
 * 清空搜索文本域中的数据
 */
function clearInput(value) {
    $("input[type='text']").val("");
    $("input[type='tel']").val("");
    $("input[type='email']").val("");
    $("input[type='date']").val("");
    // $("input[type='radio']:checked").attr("checked","");
    // $("input[type='checkbox']:checked").attr("checked","");
    // $(":checked").prop("checked", "");
    // 清除radio选中
    $('input[name=radio]').prop('checked', false);
// 清除checkbox选中
    $('input[name=checkbox]').prop('checked', false);
    $("#" + value).val("全部");
}